package com.deyili.lease.common.mybatisplus;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.util.Date;

/*
* 该类的主要作用：
* 监听mybatis的数据库行为，给creatTime，updateTime自动填充日期
* */
@Component
public class MybatisMetaObjectHandler implements MetaObjectHandler {
//    createTime指的应该是baseEntity中的字段
    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
    }
}